import urllib, urllib.request, io, os, sys, re
url = "http://music.baidu.com/search/lrc"
search = [('key','蒙娜丽莎的眼泪')]
url_String = url + "?" + urllib.parse.urlencode(search)
print(url_String)
req = urllib.request.Request(url_String)
fd = urllib.request.urlopen(req)
print(fd)
xx = fd.read()
yy = xx.decode().split("'")
i=0
while i<len(yy):
  m=re.search("\.lrc",yy[i])
  if m is not None:
    yyy = "http://music.baidu.com" + yy[i]
    print (yyy)
    fileName = "E:\\lrc\\" + str(i) +".txt"
    lrc = urllib.request.Request(yyy)
    lrc2 = urllib.request.urlopen(lrc).read()
    filehandle = open(fileName,"w",encoding='utf-8')
    filehandle.write(lrc2.decode())
    filehandle.close()
    print (fileName);
  i=i+1
